package com.gh.cloud.common.web.feign;

import com.gh.cloud.common.web.feign.fallback.UserServiceFallbackFactory;
import com.gh.cloud.commons.core.constant.ServiceNameConstants;
import com.gh.cloud.commons.core.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * @author: guohao
 * @date: 2021-02-19 11:41
 **/
@FeignClient(name = ServiceNameConstants.USER_SERVICE, fallbackFactory = UserServiceFallbackFactory.class, decode404 = true)
public interface UserService {
        /**
         * feign rpc访问远程/users/{username}接口
         * 查询用户实体对象SysUser
         *
         * @param username
         * @return
         */
        @GetMapping(value = "/users/name/{username}")
        LoginUser selectByUsername(@PathVariable("username") String username);

        /**
         * feign rpc访问远程/user/login接口
         *
         * @param username
         * @return
         */
        @GetMapping(value = "/user/login", params = "username")
        LoginUser findByUsername(@RequestParam("username") String username);

        /**
         * 通过手机号查询用户、角色信息
         *
         * @param mobile 手机号
         */
        @GetMapping(value = "/user/mobile", params = "mobile")
        LoginUser findByMobile(@RequestParam("mobile") String mobile);

        /**
         * 根据OpenId查询用户信息
         *
         * @param openId openId
         */
        @GetMapping(value = "/user/openId", params = "openId")
        LoginUser findByOpenId(@RequestParam("openId") String openId);

}
